
const { ccclass, property } = cc._decorator;

@ccclass
export default class MainUI extends cc.Component {

    //绘制界面
    @property(cc.Prefab)
    graphics: cc.Prefab = null;
    @property(cc.PhysicsBoxCollider)
    leftBian: cc.PhysicsBoxCollider = null;
    @property(cc.PhysicsBoxCollider)
    rightBian: cc.PhysicsBoxCollider = null;
    @property(cc.PhysicsBoxCollider)
    downBian: cc.PhysicsBoxCollider = null;

    onLoad() {
        //开启物理
        let manager = cc.director.getPhysicsManager();
        manager.enabled = true;

        // //绘制物理信息
        // manager.debugDrawFlags =
        //     cc.PhysicsManager.DrawBits.e_jointBit |
        //     cc.PhysicsManager.DrawBits.e_shapeBit;

        //注册
        this.node.on(cc.Node.EventType.TOUCH_START, this.touch_start, this);
        this.node.on(cc.Node.EventType.TOUCH_MOVE, this.touch_move, this);
        this.node.on(cc.Node.EventType.TOUCH_END, this.touch_end, this);
    }

    start() {
        //先准备好一个绘制界面
        this.createGraphics();
    }
    touch_start(event) {
        //每次画完在准备好一个绘制界面
        this.createGraphics();
    }
    touch_move(event) {
    }
    touch_end(event) {

    }

    createGraphics() {
        let graphics_node = cc.instantiate(this.graphics);
        this.node.addChild(graphics_node);
    }
    update(dt) { }
}
